package com.larly.exception;

import lombok.Getter;

/**
 * 错误码
 *
 * @author larly
 */
@Getter
public enum ErrorCode {


    // ===================== 通用 =====================
    SUCCESS(200, "操作成功"),
    FAIL(500, "操作失败"),
    SYSTEM_ERROR(1001, "系统异常，请稍后重试"),
    RESOURCE_NOT_FOUND(1002, "请求资源不存在"),
    REQUEST_METHOD_ERROR(1003, "请求方法错误"),
    NOT_LOGIN(1004, "未登录"),
    NO_AUTH(1005, "无权限"),

    // ===================== 参数错误 =====================
    PARAM_ERROR(2001, "参数格式错误"),
    PARAM_NOT_NULL(2002, "必填参数不能为空"),
    PARAM_OUT_OF_RANGE(2003, "参数值超出范围"),
    PARAM_TYPE_ERROR(2004, "参数类型错误"),

    // ===================== 笔记模块 =====================
    NOTE_NOT_FOUND(3001, "笔记不存在或已删除"),
    NOTE_IS_PRIVATE(3002, "该笔记为私密笔记，无访问权限"),
    NOTE_TITLE_EMPTY(3003, "笔记标题不能为空"),
    NOTE_CONTENT_EMPTY(3004, "笔记内容不能为空"),
    NOTE_CATEGORY_INVALID(3005, "笔记分类格式不合法"),
    NOTE_VERSION_NOT_FOUND(3006, "笔记历史版本不存在"),
    NOTE_DELETE_FAIL(3007, "笔记删除失败"),

    // ===================== 打卡模块 =====================
    CHECKIN_DATE_EXIST(4001, "今日已打卡，请勿重复提交"),
    CHECKIN_DATE_INVALID(4002, "打卡日期不合法"),
    CHECKIN_DURATION_INVALID(4003, "学习时长必须为正数"),
    CHECKIN_NOT_FOUND(4004, "打卡记录不存在"),

    // ===================== 互动模块 =====================
    INTERACTION_CONTENT_EMPTY(5001, "互动内容不能为空"),
    INTERACTION_NOT_FOUND(5002, "互动记录不存在或已删除"),
    INTERACTION_TYPE_INVALID(5003, "互动类型不合法"),
    INTERACTION_TOPIC_EMPTY(5004, "分享/提问类互动必须填写主题"),
    INTERACTION_PARENT_INVALID(5005, "回复的父级互动不存在"),

    // ===================== 系统配置 =====================
    SETTING_KEY_NOT_FOUND(6001, "配置项不存在"),
    SETTING_UPDATE_FAIL(6002, "配置项更新失败"),

    // ===================== 权限相关 =====================
    NO_PERMISSION(7001, "没有操作权限"),
    OPERATION_DENIED(7002, "操作被拒绝（数据已被修改）");

    /**
     * 状态码
     */
    private final int code;

    /**
     * 信息
     */
    private final String message;

    ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

}

